var wxpay = require('../../utils/pay.js')
var app = getApp();
var _openid = app.getOpenId();
Page({
  data: {
    statusType: ["未付款", "已租用", "以发布"],
    currentType: 0,
    tabClass: ["", "", "", "", ""],
    noPayList:[],
    payList:[],
    pubList:[],
    
  },
  statusTap: function (e) {
    var curType = e.currentTarget.dataset.index;
    this.data.currentType = curType
    this.setData({
      currentType: curType
    });
    this.onShow();
  },

  onLoad: function (options) {
    // 生命周期函数--监听页面加载

  },
  onReady: function () {
    // 生命周期函数--监听页面初次渲染完成

  },

  onShow: function () {
    // 获取订单列表
    wx.showLoading();
    var that = this;
    var postData = {
      token: app.globalData.token
    };
    postData.status = that.data.currentType;
    var payList ="";
    if(postData.status ==0){
        payList= "noPayList"
    }else if(postData.status == 1){
        payList="payList"
    }else{
        payList="pubList"
    }
    wx.request({
      url: app.globalData.domain + app.globalData.subDomain + '/order/list?',
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        openid:1,
        type:payList,
        },
      success: (res) => {
        var noPayList = [];
        var payList = [];
        var pubList = [];
        wx.hideLoading();
        if (res.data.code == 100) {
          that.setData({
            pubList:res.data.obj,
          });
            console.log(this.data.pubList);
        } else {
          this.setData({
            noPayList: null,
            payList: {},
            pubList: {}
          });
        }
      }
    })

  },
  

  toDetailsTap: function (e) {
    console.log(e.currentTarget.dataset.id);
    var couponsIndex = ""
     var that = this;
     var status = that.data.currentType;
     var goodsDetailId = e.currentTarget.dataset.id;
     if(status == 0){
       couponsIndex = "/pages/payOrderDetail/index?id=" + goodsDetailId
     }else if(status == 1){
       couponsIndex ="/pages/payOrderDetail/index?id=" + goodsDetailId
     }else{
       couponsIndex ="/pages/publishedParking/index?id=" + goodsDetailId
     }
      wx.navigateTo({
      url: couponsIndex
    })
  }, 

  onHide: function () {
    // 生命周期函数--监听页面隐藏

  },
  onUnload: function () {
    // 生命周期函数--监听页面卸载

  },
  onPullDownRefresh: function () {
    // 页面相关事件处理函数--监听用户下拉动作

  },
  onReachBottom: function () {
    // 页面上拉触底事件的处理函数

  }
})
